package com.aletto.general_store.ui.popup;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.aletto.general_store.R;
import com.aletto.general_store.data.model.AuctionGoods;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;

public class EditAuctionGoodsSwitchPopup extends BottomPopupView {

    private AuctionGoods item;

    public EditAuctionGoodsSwitchPopup(@NonNull Context context) {
        super(context);
    }

    public EditAuctionGoodsSwitchPopup(@NonNull Context context, AuctionGoods item) {
        super(context);
        this.item = item;
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.popup_edit_auction_goods_switch;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        findViewById(R.id.iv_close).setOnClickListener(v->dismiss());
        findViewById(R.id.layout_price).setOnClickListener(listener(EditAuctionGoodsPopup.PRICE_TYPE));
        findViewById(R.id.layout_number).setOnClickListener(listener(EditAuctionGoodsPopup.NUMBER_TYPE));
    }

    private View.OnClickListener listener(int type){
        return view -> {
            new XPopup.Builder(view.getContext())
                    .asCustom(new EditAuctionGoodsPopup(view.getContext(), item, type))
                    .show();

            dismiss();
        };
    }
}
